from pathlib import Path
from typing import TypedDict
def is_file(path:Path):
    return path.is_file() and path.exists()

def ensure_file(path:Path):
    if not is_file(path):
        raise FileNotFoundError(f"File {path.resolve()} does not exist.")

from enum import Enum
from soj.settings.compare.common import MAX_MSG_LENGTH

def translate_msg(msg:str):
    if len(msg)==0:
        return "No further infomation from jury."
    return msg[:MAX_MSG_LENGTH]+"..." if len(msg)>MAX_MSG_LENGTH else msg

class ResultCode(Enum):
    ACCEPTABLE=0,
    PRESENTATION=1,
    UNACCEPTABLE=2,
    FAILED=3,
    CUSTOM=4

from enum import Enum

class CompareType(Enum):
    FULLTEXT="fulltext"
    SYSCMD="syscmd"
    TOKEN="token"
    FLOAT="float"

#You may inherit this to add custom fields
class CompareResult(TypedDict):
    result_code:ResultCode=ResultCode.FAILED
    msg:str|None=None

class SPJCompareResult(CompareResult):
    score:int=0
